package com.example.dmdomain.entity;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.Setter;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Table(name = "application_log")
public class ApplicationLog {


	@EmbeddedId
	@JSONField(serialize = false)
	private ApplicationId applicationId = new ApplicationId();

	@Column(name = "time")
	private Date time;

	public void setApplicationId(String applicationName, String userId) {
		applicationId.setApplicationName(applicationName);
		applicationId.setUserId(userId);
	}

	public String getApplicationName(){
		return this.applicationId.getApplicationName();
	}
}
